#ifndef _N2F_RENDER_IW2D_BUTTON_H_
#define _N2F_RENDER_IW2D_BUTTON_H_

#include "..\..\core.h"
#include "..\..\Element.h"
#include "..\..\..\iw2d\h\Iw2D.h"
#include "..\..\Screen.h"
#include "Image.h"

enum N2FButtonState
{
	ButtonNormal,
	ButtonActive,
	ButtonDisabled
};

namespace N2F
{
	namespace Iw3D
	{
		class Button : public Element
		{
		public:
			typedef void (*OnClickCallback)(void *, void *);

		protected:
			struct ClickCallback
			{
				OnClickCallback callback;
				void *userData;
			};

		public:
			Button(const ScaleFactor &scaleFactor);
			~Button();

			const char *getNormalFile() const;
			void setNormalFile(const char *file);

			const char *getActiveFile() const;
			void setActiveFile(const char *file);

			const char *getDisabledFile() const;
			void setDisabledFile(const char *file);

			void setFiles(const char *normal, const char *active, const char *disabled);

			CIwFVec2 getOffset();
			void setOffset(CIwFVec2 offset);

			float getScale();
			void setScale(float scale);

			const N2FButtonState getState() const;
			void setState(const N2FButtonState state);

			void buildHitBox();

			void OnClick(OnClickCallback callback, void *userData);

			virtual void draw(int64 delta);
			virtual void draw(int64 delta, CIwFVec2 offset);
			virtual void draw(int64 delta, CIwFVec2 offset, float angle);
			virtual void draw(int64 delta, CIwFVec2 offset, float angle, float scale);

			virtual void OnKill();
			virtual void OnTouch(InputPoint point);
			virtual bool isHit(CIwFVec2 point);

		protected:
			Image *imgNormal, *imgActive, *imgDisabled;
			ClickCallback clickCallback;
			Rectangle *hitBox;
			N2FButtonState state;
			CIwFVec2 offset;
			float scale;
		};
	}
}

#endif
